define(['../../dist/rnexui', 'react', 'react-dom'], function (_rnexui, _react, _reactDom) {
	'use strict';

	var _react2 = _interopRequireDefault(_react);

	var _reactDom2 = _interopRequireDefault(_reactDom);

	function _interopRequireDefault(obj) {
		return obj && obj.__esModule ? obj : {
			default: obj
		};
	}

	function _classCallCheck(instance, Constructor) {
		if (!(instance instanceof Constructor)) {
			throw new TypeError("Cannot call a class as a function");
		}
	}

	var _createClass = function () {
		function defineProperties(target, props) {
			for (var i = 0; i < props.length; i++) {
				var descriptor = props[i];
				descriptor.enumerable = descriptor.enumerable || false;
				descriptor.configurable = true;
				if ("value" in descriptor) descriptor.writable = true;
				Object.defineProperty(target, descriptor.key, descriptor);
			}
		}

		return function (Constructor, protoProps, staticProps) {
			if (protoProps) defineProperties(Constructor.prototype, protoProps);
			if (staticProps) defineProperties(Constructor, staticProps);
			return Constructor;
		};
	}();

	function _possibleConstructorReturn(self, call) {
		if (!self) {
			throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
		}

		return call && (typeof call === "object" || typeof call === "function") ? call : self;
	}

	function _inherits(subClass, superClass) {
		if (typeof superClass !== "function" && superClass !== null) {
			throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
		}

		subClass.prototype = Object.create(superClass && superClass.prototype, {
			constructor: {
				value: subClass,
				enumerable: false,
				writable: true,
				configurable: true
			}
		});
		if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
	}

	var idx = 1;

	var Dialog = function (_React$Component) {
		_inherits(Dialog, _React$Component);

		function Dialog() {
			_classCallCheck(this, Dialog);

			return _possibleConstructorReturn(this, (Dialog.__proto__ || Object.getPrototypeOf(Dialog)).apply(this, arguments));
		}

		_createClass(Dialog, [{
			key: 'render',
			value: function render() {
				var _props = this.props,
				    visible = _props.visible,
				    container = _props.container;


				return visible ? _react2['default'].createElement(
					_rnexui.Portal,
					{ container: container },
					_react2['default'].createElement(
						'div',
						{ className: 'popup' },
						'Body...',
						idx++
					),
					_react2['default'].createElement(
						'div',
						{ className: 'popup' },
						'Body...',
						idx++
					)
				) : null;
			}
		}]);

		return Dialog;
	}(_react2['default'].Component);

	var visible = true;

	var App = function (_React$Component2) {
		_inherits(App, _React$Component2);

		function App() {
			var _ref;

			var _temp, _this2, _ret;

			_classCallCheck(this, App);

			for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
				args[_key] = arguments[_key];
			}

			return _ret = (_temp = (_this2 = _possibleConstructorReturn(this, (_ref = App.__proto__ || Object.getPrototypeOf(App)).call.apply(_ref, [this].concat(args))), _this2), _this2.handleClick = function () {
				visible = !visible;
				_this2.forceUpdate();
			}, _temp), _possibleConstructorReturn(_this2, _ret);
		}

		_createClass(App, [{
			key: 'render',
			value: function render() {
				return _react2['default'].createElement(
					'div',
					null,
					_react2['default'].createElement(
						'button',
						{ onClick: this.handleClick },
						'toggle'
					),
					_react2['default'].createElement(Dialog, { visible: visible, container: d0 }),
					_react2['default'].createElement(Dialog, { visible: visible })
				);
			}
		}]);

		return App;
	}(_react2['default'].Component);

	_reactDom2['default'].render(_react2['default'].createElement(App, null), demo);
});